﻿namespace EasyOAuth.Core.Web
{
    /// <summary>
    /// 扩展分页
    /// </summary>
    public static class ApiResExtension
    {

        /// <summary>
        /// 返回分页数据  
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="data"></param>
        /// <param name="total"></param>
        /// <returns></returns>
        public static ApiPageResult<T> ToPageResult<T>(this T data, int total = 0) where T : class, new()
        {
            return new ApiPageResult<T>()
            {
                Rows = data,
                Total = total
            };
        }
    }
}
